package com.cby.android.base

import android.app.Application
import android.app.NotificationChannel
import android.app.NotificationManager
import android.os.Build
import androidx.annotation.RequiresApi

/**
 * @description: MyApplication
 * @author: ChenBaoYang
 * @createDate: 2022/7/21 10:35 上午
 */
class MyApplication : Application() {

    companion object{
        const val SCREEN_CAPTURE_CHANNEL_ID = "100"
        const val SCREEN_CAPTURE_CHANNEL_NAME = "capture"
    }

    @RequiresApi(Build.VERSION_CODES.O)
    override fun onCreate() {
        super.onCreate()
        createScreenCaptureNotificationChannel()
    }

    @RequiresApi(Build.VERSION_CODES.O)
    private fun createScreenCaptureNotificationChannel() {
        val notificationManager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager
        // Create the channel for the notification
        val screenCaptureChannel = NotificationChannel(SCREEN_CAPTURE_CHANNEL_ID, SCREEN_CAPTURE_CHANNEL_NAME, NotificationManager.IMPORTANCE_LOW)
        // Set the Notification Channel for the Notification Manager.
        notificationManager.createNotificationChannel(screenCaptureChannel)
    }
}